// 引入express
const express = require('express')
// 引入连接池模块
const pool = require('../pool.js')
const router = express.Router()

// 查看所有省份
// http://localhost:3000/dw/

router.get('/', (req, res, next) => {
  pool.query('select * from qnls_province', (err, r) => {
    if (err) {
      return next(err)
    }
    res.send({ code: 200, msg: '所有定位省份', data: r })
  })
})


// 通过城市编号查询城市
// http://localhost:3000/dw/pid
router.post('/pid',(req,res,next) => {
  var obj = req.body
  pool.query('select * from qnls_province where pid=?',[obj.pid],(err,r) => {
      if(err){
          return next(err)
      }
      res.send({
          code:200,msg:'查询成功',data:r
      })
  })
})
module.exports = router
